<div id="error"></div>
<script language="javascript">
    // apply filters
    var applyFilter = function()
    {
        
    }
    
    jQuery(document).ready(function(){
        jQuery("#list").jqGrid({
            url: '<?php echo site_url() ?>/tipooutbound/data',
            mtype: 'POST',
            datatype: 'json',
            colNames:['ID','Detalle T.Outbound'],
            colModel :[
                {name:'id', index:'IdOutbound', width:10,hidden:true},
                {name:'OutboundTipo', index:'OutboundTipo', width:250}],
            pager: jQuery('#pager'),
            hiddengrid: false,
            sortname: 'id',
            rowNum:10,
            rowList:[10,20,30,40,50],
            sortorder: "asc",
            height: '100%',
            width: '550',
            imgpath: _base_url + 'public/css/jqgrid/flex/images',
            viewrecords: true,
            multiselect: true,
            adjacents: 4,
            jsonReader: { repeatitems : false, id: "0" }
        }).navGrid('#pager',{add:false,del:false,edit:false,search:false,position:"left"})
        .navButtonAdd('#pager',{caption:"", buttonimg: _base_url + "public/css/jqgrid/flex/images/text_columns.png", onClickButton:function(){ jQuery("#list").setColumns();} })
        .navButtonAdd('#pager',{caption:"Agregar", buttonimg: _base_url + "public/images/new.png", onClickButton:function(){ window.location = _site_url + "/tipooutbound/add"; } })
        .navButtonAdd('#pager',{caption:"Editar", buttonimg: _base_url + "public/images/edit.png", onClickButton:function(){ var id = jQuery('#list').getGridParam('selarrrow');
        if (id.length > 0) {
            if(id.length == 1){
                var ret = jQuery("#list").getRowData(id);
                window.location = _site_url + '/tipooutbound/edit/' + ret.id;
            } else { jAlert('Seleccione solo una etapa'); }
        } else { jAlert('Debe seleccionar al menos una etapa'); }
        return false; } }).navButtonAdd('#pager',{caption:"Eliminar", buttonimg: _base_url + "public/images/delete.png", onClickButton:function(){ var id = jQuery('#list').getGridParam('selarrrow');
        if (id.length > 0) {
            var msg = '';
            if(id.length == 1) msg = 'Realmente desea eliminar esta registro?';
            else msg = 'Realmente desea eliminar este ' + id.length + ' Registro?';
            jConfirm(msg, 'Dialogo de Confirmacion', function (r) {
                if(r) {
                    var ids_to_delete = new Array();
                    for (var i = 0; i < id.length; i++){
                        var ret = jQuery("#list").getRowData(id[i]);
                        ids_to_delete[i] = ret.id
                    }

                    $.post( _site_url + '/tipooutbound/delete', { delete_rows: ids_to_delete.join("|") }, function(data){
                        $('#error').html(data); jQuery("#list").setGridParam({ postData:{ search: false }}).trigger("reloadGrid");
                    });
                }
            });
        } else { jAlert('Debe seleccionar al menos una etapa'); }

        return false;} }); $('#apply_filter').bind('click', applyFilter);
    });
</script>
<div class="table_container">
<table>
    <tr>
    	<td><div id="titulo">Tipo de Outbound</div><?php $this->load->view('etapas_filters'); ?></td>
    </tr>
    <tr>
        <td>
            <table id="list" class="scroll"></table>
            <div id="pager" class="scroll" style="text-align:center;"></div>
        </td>
	</tr>
 </table>
</div>